import {
    Cell
} from "./cell.js"

class Fence {
    attrTitle // 属性名
    attrId
    specs //一组相同属性的规格值
    cells = [] //[{cell} {cell}] 

    constructor(specs) {
        this.specs = specs
        this.attrTitle = specs[0].key
        this.attrId = specs[0].key_id
    }

    init() {
        this._initCells()
    }

    _initCells() {
        this.specs.forEach(item => {
            // 去重
            let isHas = this.cells.some(cell => {
                return cell.id === item.value_id
            })
            if (isHas) {
                return
            }
            const cell = new Cell(item)
            this.cells.push(cell)
        })
    }

    // pushValue(value) {
    //     this.arrtValueArr.push(value)
    // }
}

export {
    Fence
}